#ifndef SOCCERPITCH_H
#define SOCCERPITCH_H
//------------------------------------------------------------------------
//
//  Name:   State.h
//
//  Desc:   abstract base class to define an interface for a state
//
//  Author: Mat Buckland (fup@ai-junkie.com)
//
//------------------------------------------------------------------------


#include "OgreRefAppStateMachine.h"
#include "OgreRefAppApplicationObject.h"

namespace OgreRefApp
{

    class Region;
    class Goal;
    class SoccerTeam;
    class Ball;
    class ApplicationObject;


    class _OgreRefAppExport SoccerPitch
    {
    public:

        Ball*          m_pBall;

        SoccerTeam*          m_pRedTeam;
        SoccerTeam*          m_pBlueTeam;

        Goal*                m_pRedGoal;
        Goal*                m_pBlueGoal;
        FinitePlane* m_pPlane;


        //defines the dimensions of the playing area
        Region*              m_pPlayingArea;

        //the playing field is broken up into regions that the team
        //can make use of to implement strategies.
        std::vector<Region*> m_Regions;

        //true if a goal keeper has possession
        bool                 m_bGoalKeeperHasBall;

        //true if the game is in play. Set to false whenever the players
        //are getting ready for kickoff
        bool                 m_bGameOn;

        //set true to pause the motion
        bool                 m_bPaused;

        //local copy of client window dimensions
        int                  m_cxClient,
        m_cyClient;

        //this instantiates the regions the players utilize to  position
        //themselves
        void createRegions(Real width, Real height);


    public:

        SoccerPitch(int cxClient, int cyClient);

        ~SoccerPitch();

        void  update();

        //bool  Render();

        void  togglePause()
        {
            m_bPaused = !m_bPaused;
        }
        bool  paused()const
        {
            return m_bPaused;
        }

        int   cxClient()const
        {
            return m_cxClient;
        }
        int   cyClient()const
        {
            return m_cyClient;
        }

        bool  goalKeeperHasBall()const
        {
            return m_bGoalKeeperHasBall;
        }
        void  setGoalKeeperHasBall(bool b)
        {
            m_bGoalKeeperHasBall = b;
        }

        Region*         playingArea()
        {
            return m_pPlayingArea;
        }
        Ball*           ball()
        {
            return m_pBall;
        }

        Region* getRegionFromIndex(int idx)
        {
            assert ( (idx >= 0) && (idx < m_Regions.size()) );

            return m_Regions[idx];
        }

        bool  gameOn()const
        {
            return m_bGameOn;
        }
        void  setGameOn()
        {
            m_bGameOn = true;
        }
        void  setGameOff()
        {
            m_bGameOn = false;
        }
    };
}
#endif
